CREATE TABLE [ext].[evento]
(
[id_evento] [int] NOT NULL IDENTITY(1, 1),
[id_utilizador] [uniqueidentifier] NOT NULL,
[id_categoria] [int] NULL,
[data_inicio] [date] NOT NULL,
[data_fim] [date] NOT NULL,
[titulo] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[descricao] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[preco] [money] NULL,
[morada] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[codigo_postal] [varchar] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[url] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[contato_telefonico] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[latitude] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[longitude] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[cancelado] [bit] NOT NULL CONSTRAINT [DF__evento__cancelad__16CE6296] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [ext].[evento] ADD CONSTRAINT [PK_evento] PRIMARY KEY CLUSTERED  ([id_evento]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_evento] ON [ext].[evento] ([id_utilizador]) ON [PRIMARY]
GO
ALTER TABLE [ext].[evento] ADD CONSTRAINT [FK_evento_categoria] FOREIGN KEY ([id_categoria]) REFERENCES [ext].[categoria] ([id_categoria])
GO
ALTER TABLE [ext].[evento] ADD CONSTRAINT [FK_evento_utilizador] FOREIGN KEY ([id_utilizador]) REFERENCES [ext].[utilizador] ([id_utilizador])
GO
